/*
* Copyright (c) 2008 by Windward Studios, Inc. All rights reserved.
*
* This software is the confidential and proprietary information of
* Windward Studios ("Confidential Information").  You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Windward Studios, Inc.
*/

using System.Collections.ObjectModel;

namespace Kailua.net.windward.controls
{
	/// <summary>
	/// Defines a range in a LinkTreeNode that has a link similiar to a link in a web page.
	/// </summary>
	public class LinkTreeNodeChunk
	{
		private readonly int start;
		private readonly int length;
		private bool visited;
		private readonly object tag;

		/// <summary>
		/// Create the object.
		/// </summary>
		/// <param name="start">The character offset of the start of the link in the node text.</param>
		/// <param name="length">The number of characters long the link is.</param>
		/// <param name="tag">A tag assigned to the chunk.</param>
		public LinkTreeNodeChunk(int start, int length, object tag)
		{
			this.start = start;
			this.length = length;
			visited = false;
			this.tag = tag;
		}

		/// <summary>
		/// The character offset of the start of the link in the node text.
		/// </summary>
		internal int Start
		{
			get { return start; }
		}

		/// <summary>
		/// The number of characters long the link is.
		/// </summary>
		internal int Length
		{
			get { return length; }
		}

		/// <summary>
		/// Set if the link should be drawn in the visited style.
		/// </summary>
		public bool Visited
		{
			get { return visited; }
			set { visited = value; }
		}

		/// <summary>
		/// The tag assigned to the chunk.
		/// </summary>
		internal object Tag
		{
			get { return tag; }
		}
	}

	/// <summary>
	/// A collection of LinkTreeNodeChunk objects.
	/// </summary>
	public class LinkTreeNodeChunkCollection : Collection<LinkTreeNodeChunk>
	{
		/// <summary>
		/// Add a new LinkTreeNodeChunk object to the collection.
		/// </summary>
		/// <param name="start">The character offset of the start of the link in the node text.</param>
		/// <param name="length">The number of characters long the link is.</param>
		/// <param name="tag">A tag assigned to the chunk.</param>
		public void Add(int start, int length, object tag)
		{
			Add(new LinkTreeNodeChunk(start, length, tag));
		}
	}
}